import os
import sys
import re

if __name__ == '__main__':
    for row in sys.stdin:
        if row.strip() != '':
            host = row.split(':')[0]
            friends_l = row.split(':')[1].strip().split(' ')

            for a in range(0, len(friends_l) - 1):
                for b in range(1, len(friends_l) - 1):
                    print(friends_l[a], friends_l[b], host)